import Mock from 'mockjs'

var milepost = Mock.mock({
  'list|10': [{
    'markId|+100': 10000,
    'markName|+1': "里程碑@markId",
    "phaseName": "阶段@markId",
    remark: '这是备注',
    createDate: '@date(yyyy-MM-dd)',
    'children|1-10': [{
      'phaseId': '00@id',
      phaseName: '阶段00@id',
      remark: '@csentence(0,50)'
    }]
  }]
})
export default [

  //获取里程碑
  {
    url: '/task/milepost/getPageList',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: {
          pageSize: 10,
          currentPage: 1,
          totalPages: 3,
          totalCount: 30,
          list: milepost.list
        },
        msg: "请求成功"
      }
    }
  },
  // 里程碑删除
  {
    url: '/task/milepost/del',
    type: 'post',
    response: config => {
      const { id } = config.body
      if (!id) {
        return {
          code: 403,
          msg: '删除失败',
          data: null
        }
      }
      return {
        code: 20000,
        msg: '处理成功',
        data: id
      }
    }
  },
  // 里程碑增加
  {
    url: '/task/milepost/add',
    type: 'post',
    response: config => {
      const { markName, remark, phase } = config.body
      if (!markName || !phase) {
        return {
          code: 20203,
          msg: 'markName and phase is require',
          data: null
        }
      }
      return {
        code: 20000,
        msg: '处理成功',
      }
    }
  },
  // 里程碑修改
  {
    url: '/task/milepost/edit',
    type: 'post',
    response: config => {
      const { id, markName, remark } = config.body
      if (!markName || !id) {
        return {
          code: 20203,
          msg: 'id and markName is require',
          data: null
        }
      }
      return {
        code: 20000,
        msg: '处理成功',
      }
    }
  },


  // 里程碑阶段删除
  {
    url: '/task/phases/del',
    type: 'post',
    response: config => {
      const { id } = config.body
      if (!id) {
        return {
          code: 403,
          msg: '删除失败',
          data: null
        }
      }
      return {
        code: 20000,
        msg: '处理成功',
        data: id
      }
    }
  },
  // 里程碑阶段增加
  {
    url: '/task/phases/add',
    type: 'post',
    response: config => {
      const { phaseName } = config.body
      if (!phaseName) {
        return {
          code: 20203,
          msg: 'phaseName is require',
          data: null
        }
      }
      return {
        code: 20000,
        msg: '处理成功',
      }
    }
  },
  // 里程碑修改
  {
    url: '/task/phases/edit',
    type: 'post',
    response: config => {
      const { id, phaseName } = config.body
      if (!phaseName || !id) {
        return {
          code: 20203,
          msg: 'id and phaseName is require',
          data: null
        }
      }
      return {
        code: 20000,
        msg: '处理成功',
      }
    }
  },

]